import React, { Component } from 'react'



const withKaikeba=Comp=>{
  //console.log(Comp.name+"渲染了")
  const name='高阶组件';
  return class Aaa extends React.Component{
    componentDidMount() {
     // console.log('do something')
    }
    render(){
      return <Comp {...this.props} name={name} />
    }
  }
}

const withLog=Comp=>{
  //console.log(Comp.name+"渲染了")
  return props=><Comp {...props}/>
}


//装饰器必须用在class类上,,,,不能用在function
@withLog
@withKaikeba
@withLog
class Kaikeba extends Component{
  render(){
    return (
      <div>
        {this.props.stage}---{this.props.name}
      </div>
    )
  }
}

//多层高阶组件
//const NewKaikeba=withLog(withKaikeba(withLog(Kaikeba)))

export default class Hoc extends Component {
  render() {
    return (
      <div>
        <Kaikeba stage='React'></Kaikeba>
      </div>
    )
  }
}
